var e = require, t = module, n = exports;

Object.defineProperty(n, "__esModule", {
    value: !0
}), n.EggData = n.EggConfig = n.EggType = void 0;

var o, i = e("GameConfig");

!function(t) {
    t[t.GUN = 1] = "GUN", t[t.PERSON = 2] = "PERSON", t[t.PET = 3] = "PET";
}(o = n.EggType || (n.EggType = {}));

var a = function(t) {
    this.count = 1, this.flag = 1, this.idx = t;
};

n.EggConfig = a;

var r = function(t) {
    this.count = 0, this.time = 0, this.flag = 0, this.idx = t;
};

n.EggData = r;

var s = function() {
    function t() {
        this.eggConfigMap = new Map(), this.eggPConfigMap = new Map(), this.eggCConfigMap = new Map(), 
        this.eggDataMap = new Map(), this.eggPDataMap = new Map(), this.eggCDataMap = new Map();
    }
    return t.getInstance = function() {
        return this._manager || (this._manager = new t()), this._manager;
    }, t.prototype.checkEggGun = function(t) {
        return this.checkEgg(t, o.GUN);
    }, t.prototype.checkEggPerson = function(t) {
        return this.checkEgg(t, o.PERSON);
    }, t.prototype.checkEggPet = function(t) {
        return this.checkEgg(t, o.PET);
    }, t.prototype.checkEggTimeGun = function(t) {
        return this.checkEggTime(t, o.GUN);
    }, t.prototype.checkEggTimePerson = function(t) {
        return this.checkEggTime(t, o.PERSON);
    }, t.prototype.checkEggTimePet = function(t) {
        return this.checkEggTime(t, o.PET);
    }, t.prototype.updateEggGun = function(t) {
        return this.updateEgg(t, o.GUN);
    }, t.prototype.updateEggPerson = function(t) {
        return this.updateEgg(t, o.PERSON);
    }, t.prototype.updateEggPet = function(t) {
        return this.updateEgg(t, o.PET);
    }, t.prototype.setDataGun = function(t, e) {
        return this.setData(t, e, o.GUN);
    }, t.prototype.setDataPerson = function(t, e) {
        return this.setData(t, e, o.PERSON);
    }, t.prototype.setDataPet = function(t, e) {
        return this.setData(t, e, o.PET);
    }, t.prototype.getDataGun = function(t) {
        return this.getData(t, o.GUN);
    }, t.prototype.getDataPerson = function(t) {
        return this.getData(t, o.PERSON);
    }, t.prototype.getDataPet = function(t) {
        return this.getData(t, o.PET);
    }, t.prototype.setData = function(t, e, n) {
        void 0 === n && (n = o.GUN);
        n = this.getDataMap(n);
        n && n.set(t, e);
    }, t.prototype.getData = function(t, e) {
        void 0 === e && (e = o.GUN);
        e = this.getDataMap(e);
        return e ? e.get(t) : null;
    }, t.prototype.checkEgg = function(t, e) {
        void 0 === e && (e = o.GUN);
        var n = this.getConfigMap(e);
        if (!n) return -2;
        n.has(t) || n.set(t, new a(t));
        n = n.get(t);
        if (!n.flag) return -2;
        e = this.getDataMap(e);
        if (!e) return -1;
        if (!e.has(t)) return -1;
        t = e.get(t);
        return t.flag ? (isNaN(t.count) && (t.count = 0), Math.max((isNaN(n.count) ? i.GC.eggCount : n.count) - t.count, 0)) : -1;
    }, t.prototype.updateEgg = function(t, e) {
        void 0 === e && (e = o.GUN);
        var n, g, u = this.getConfigMap(e);
        u && (u.has(t) || u.set(t, new a(t)), g = u.get(t), (n = this.getDataMap(e)) && (n.has(t) || n.set(t, new r(t)), 
        (u = n.get(t)).flag || (u.flag = 1), isNaN(u.count) && (u.count = 0), g = isNaN(g.count) ? i.GC.eggCount : g.count, 
        u.count < g ? (u.count++, n.set(t, u), cc.log("彩蛋类型：" + e + "，彩蛋序号：" + t + "，免费使用")) : (n.set(t, u), 
        cc.log("彩蛋类型：" + e + "，彩蛋序号：" + t + "，视频使用"))));
    }, t.prototype.checkEggTime = function(t, e) {
        void 0 === e && (e = o.GUN);
        e = this.getDataMap(e);
        return e ? (e.has(t) || e.set(t, {
            idx: t,
            time: Date.now(),
            flag: 1
        }), e.get(t).time - Date.now()) : 0;
    }, t.prototype.getConfigMap = function(t) {
        switch (t = void 0 === t ? o.GUN : t) {
          case o.GUN:
            return this.eggConfigMap;

          case o.PERSON:
            return this.eggPConfigMap;

          case o.PET:
            return this.eggCConfigMap;

          default:
            return null;
        }
    }, t.prototype.getDataMap = function(t) {
        switch (t = void 0 === t ? o.GUN : t) {
          case o.GUN:
            return this.eggDataMap;

          case o.PERSON:
            return this.eggPDataMap;

          case o.PET:
            return this.eggCDataMap;

          default:
            return null;
        }
    }, t._manager = null, t;
}();

n.default = s;